<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>原生ajax</title>
  <script>
    window.onload = function () {
      let btn1 = document.querySelector('#btn1');
      btn1.onclick = function () {
        console.log('点击了');
        let ajax = new XMLHttpRequest();
        ajax.open('get', 'http://localhost:9123/aaa', true);
        ajax.send()


        ajax.onreadystatechange = function () {
          console.log(ajax);
          if (ajax.readyState == 4) {
            if (ajax.status >= 200 && ajax.status < 300 || ajax.status == 304) {
              console.log('成功了')
              console.log(ajax.responseText)

            }

          }

        }



      }

    }

  </script>
</head>

<body>
  <button id="btn1">发送请求</button>



</body>

</html>